<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class BaseModel extends Model
{
    use HasFactory;

    /**
     * 创建时间
     */
    const CREATED_AT = 'created_at';

    /**
     * 更新时间
     */
    const UPDATED_AT = 'updated_at';

    /**
     * 时间戳格式化
     * @param \DateTimeInterface $date
     * @return string
     */
    protected function serializeDate(\DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i:s');
    }

    /**
     * 获取属性值;
     * @param array $attrbiute
     * @return array
     */
    protected function getAttributeVal(array $attrbiute)
    {
        return array_column($attrbiute, 'label', 'value');
    }
}
